﻿using System;
using System.Collections.ObjectModel;
using Avalonia.Controls;
using iOSClub.App.Desktop.Pages;
using iOSClub.App.Share;

namespace iOSClub.App.Desktop.ViewModels.Pages;

[Serializable]
public class SignupPageModel : PageModelBase
{
    public override Control Init()
    {
        return new SignupPage() { DataContext = this };
    }

    private string _userName = "";

    public string UserName
    {
        get => _userName;
        set => SetProperty(ref _userName, value);
    }

    private string _userId = "";

    public string UserId
    {
        get => _userName;
        set => SetProperty(ref _userId, value);
    }

    private string _academy = "";

    public string Academy
    {
        get => _userName;
        set => SetProperty(ref _academy, value);
    }

    private string _politicalLandscape = "";

    public string PoliticalLandscape
    {
        get => _userName;
        set => SetProperty(ref _politicalLandscape, value);
    }

    private string _gender = "";

    public string Gender
    {
        get => _userName;
        set => SetProperty(ref _gender, value);
    }

    private string _className = "";

    public string ClassName
    {
        get => _userName;
        set => SetProperty(ref _className, value);
    }

    private string _phoneNum = "";

    public string PhoneNum
    {
        get => _userName;
        set => SetProperty(ref _phoneNum, value);
    }

    public string[] PoliticalLandscapes { get; } =
    [
        "群众",
        "共青团员",
        "中共党员",
        "中共预备党员"
    ];

    public string[] Genders { get; } = ["男", "女"];

    public ObservableCollection<string> Academies { get; set; } = [];

    public StudentModel? GetStudentModel()
    {
        if (string.IsNullOrEmpty(UserId) || string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(Academy) ||
            string.IsNullOrEmpty(ClassName) || string.IsNullOrEmpty(Gender) || string.IsNullOrEmpty(PhoneNum) ||
            string.IsNullOrEmpty(PoliticalLandscape)) return null;
        return new StudentModel()
        {
            UserId = UserId,
            UserName = UserName,
            Academy = Academy,
            ClassName = ClassName,
            Gender = Gender,
            PoliticalLandscape = PoliticalLandscape,
            PhoneNum = PhoneNum
        };
    }
}